package cn.itsource.util;

import cn.itsource.domain.User;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class UserContext {
    private static Map<String, User> concurrentHashMap = new ConcurrentHashMap<>();

    // 存入令牌
    public static void setByNamePassword(String token, User user){
        concurrentHashMap.put(token, user);
    }

    // 根据令牌查询用户
    public static User getUser(String token){
        User user = concurrentHashMap.get(token);
        return user;
    }

    private static int code = 0;

    public static void setCode(int i){
        code = i;
    }

    public static int getCode(){
        return code;
    }

}
